import http from "@/api/config/http";
import { IQuery, IResponse, ITableResponse } from "@/interface/IAxios";
import { LibraryType } from "../library/types";

export interface CrossResource {
  link: string;
  width: number;
  height: number;
  size: number;
  offsetX: number;
  offsetY: number;
  type: LibraryType;
}
export interface Cross {
  id?: number;
  name: string;
  num: number;
  resource: CrossResource[];
  deptId: string;
}
export const listCross = (query?: IQuery) =>
  http.request<ITableResponse<Cross>>({
    url: `/device/cross/list`,
    method: "get",
    params: query
  });

export const addCross = (data: Cross) =>
  http.request<IResponse<Cross>>({
    url: `/device/cross`,
    method: "post",
    data
  });

export const delCross = (id: string) =>
  http.request<Cross>({
    url: `/device/cross/${id}`,
    method: "delete"
  });

export const updateCross = (data: Cross) =>
  http.request<IResponse<Cross>>({
    url: `/device/cross/`,
    method: "put",
    data
  });
export const detailCross = (id: string) =>
  http.request<IResponse<Cross>>({
    url: `/device/cross/${id}`,
    method: "get"
  });
